var leftTotal,rightTotal;
function addConfirmer(left,right,total) {
	leftTotal =  document.getElementById(left).options.length;
	for (i = 0; i < leftTotal; i++) {
   		if (document.getElementById(left).options(i).selected == true) {
  	 		j = document.getElementById(right).length - 1;
  	 		for (; j >= 0; j--) {
  	 			if (document.getElementById(left).item(i).value == document.getElementById(right).item(j).value) {
 	  				break;
  	 			}
  			}
   			if (j < 0) {
  				newOpt = new Option(document.getElementById(left).item(i).text, document.getElementById(left).item(i).value);
   				document.getElementById(right).add(newOpt);
  			}
  		}
	}
}



function addall(left,right,total) {
	var i,j;
	leftTotal =  document.getElementById(left).options.length;
	for (i=0;i<leftTotal;i++) {
   		j =document.getElementById(right).options.length - 1;
   		for (; j >= 0; j--){
   			if (document.getElementById(left).item(i).value ==document.getElementById(right).item(j).value) {
   				break;
   			}
		}
  	 	if (j < 0) {
  			 newOpt = new Option(document.getElementById(left).item(i).text, document.getElementById(left).item(i).value);
  		 	 document.getElementById(right).add(newOpt);
		}
	}
}


function removeConfirmer(right,total) {
	var i;
	rightTotal = document.getElementById(right).options.length;
	for (i =  rightTotal- 1; i >=0; i--) {
   		if (document.getElementById(right).options(i).selected == true) {
   			document.getElementById(right).remove(i);
   		}
	}
}


function removeall(right,total) {
	rightTotal = document.getElementById(right).options.length;
	for (i = rightTotal - 1; i >= 0; i--) {
		document.getElementById(right).remove(i);
	}
}

function gettotal(right,total){
	var totalarr,i,j;
	document.getElementById(total).value="";
	j = 0;
	arrTotal = new Array();
	rightTotal = document.getElementById(right).options.length;
	/*
	for (i = rightTotal -1; i >= 0; i--) {
		arrTotal[j] = document.getElementById(right).item(i).value;
		j++;
	}
	*/
	for (i = 0; i <= rightTotal -1; i++) {
		arrTotal[j] = document.getElementById(right).item(i).value;
		j++;
	}
	document.getElementById(total).value = arrTotal.join(',');
}